Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

202
Visualizações
How to delete picture in a channel | DJS

I would like to be able to delete an image sent automatically. But ONLY the pictures and not all the attachments.

I'm currently using message.attachments.size > 0. But I know that removes all attachments; what I don't want!

    async execute(message, client) {
    if (!message.guild || message.author.bot) return;

    if (message.channel.id === 'CHANNEL-ID' && message.attachments.size > 0) {
            message.delete()
    }

With my research, I came across a post explaining that it was enough to add filters; message.attachments.find(attachment => attachment.filename.endsWith('png') || attachment.filename.endsWith('jpg') || attachment.filename.endsWith('gif'))

But for me it does not work; shows me an error, it does not seem to recognize the .endsWith

node version: 16.13.2 | npm version: 8.1.2

Thanks in advance ! 👨🏻‍💻

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

There is no property called filename in a MessageAttachment. Instead, it has a name property which I believe you can use. So you just need to replace the filename property with attachment.name

about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda